package com.horse.pack.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum HorseErrorCodeEnum implements ServerCode {

    /**
     * 入职错误码
     */
    SUCCESS(0, "success"),
    NO_LOGIN(-101, "未登录"),
    FREQUENT_REQUESTS(102, "请求过于频繁，请稍后再试"),
    //三位 服务器异常
    INVALID_PARAMETERS_ERROR(400, "请求异常"),
    UNAUTHORIZED(403, "无权限访问"),
    METHOD_ARGUMENT_VALID_DEFAULT_ERROR(406, "参数校验失败"),
    INTERNAL_SERVER_ERROR(500, "%s%s系统繁忙"),
    SERVER_ERROR(501, "系统异常"),

    HTTP_MEDIA_TYPE_NOT_SUPPORT_ERROR(501, "MediaType 不支持"),
    REQUEST_INFO_NULL(504, "入参为空"),
    OPEN_TOKEN_NULL(-505, "token为空"),

    ;

    Integer code ;

    String msg ;

    public static String getMessage(Integer code) {
        for (HorseErrorCodeEnum entryErrorCodeEnum : values()) {
            if (entryErrorCodeEnum.getCode().equals(code)) {
                return entryErrorCodeEnum.msg;
            }
        }
        return null;
    }
}
